package zy;

public class MyThread {
	public volatile boolean flag = false;

	public void printdigit() {
		synchronized (this) {
			for (int i = 1; i <= 52; i++) {
				System.out.print(i);
				while (flag && i % 2 == 0) {
					try {
						this.wait();
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
				}
				flag = true;
				this.notifyAll();

			}
		}
	}

	public void printdata() {
		synchronized (this) {
			for (int i = 0; i <= 25; i++) {
				while (!flag) {
					try {
						this.wait();
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
				}
				System.out.print((char) ('A' + i));
				flag = false;
				this.notifyAll();
			}
		}

	}
}
